package com.mybatis;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;
import java.util.Map;

@Controller
public class MyController {

	@Autowired
	EmployeeService employeeService;
	@RequestMapping("/getemps")
	public String getemps(Model map){
		List<Employee> emps = employeeService.getEmps();
		map.addAttribute("emps",emps);

		return "list";
	}

	@RequestMapping("/add")
	public String addOne(Model map){
		Employee employee = new Employee();
		employee.setLastName("heiMan");
		employee.setEmail("qwe2@qq.com");
		employee.setGender("2");
		int num = employeeService.addOne(employee);
		map.addAttribute("result",num);
		return "add";
	}
}
